<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>资金到位</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/buttons.css" />
<link rel="stylesheet" type="text/css" href="/jxcsxm/js/autocomplete/jquery.autocomplete.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-form.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/datagrid-detailview.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/util/jquery.cookie.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/YMLib.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/YWLib.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/autocomplete/jquery.autocomplete.js" ></script>
<style type="text/css">.table{border: 1px solid #FFE7BA;} .table tr{border: 1px solid #FFE7BA;} .table tr td{border: 1px solid #FFE7BA;}</style>
<script type="text/javascript">
function yzsz(id){
	if(isNaN(Number($(id).val()))){  
		//当输入不是数字的时候，Number后返回的值是NaN;然后用isNaN判断。
        alert('请填入数字！');
        $(id).val('');
		$(id).focus();
    }
}
function bcsqbfje(id){
	if(isNaN(Number($(id).val()))){  
		//当输入不是数字的时候，Number后返回的值是NaN;然后用isNaN判断。
        alert('请填入数字！');
        $(id).val('');
		$(id).focus();
    }
}
function yhjhje(id){
	if(isNaN(Number($(id).val()))){  
		//当输入不是数字的时候，Number后返回的值是NaN;然后用isNaN判断。
        alert('请填入数字！');
        $(id).val('');
		$(id).focus();
    }
	else{
		sumye(parent.YMLib.Var.data.id);
	}
	
}


$(function(){
	$("#id").val(parent.YMLib.Var.data.id);
	$("#bcje").val(parent.YMLib.Var.data.bcje);
	$("#zhjhje").val(parent.YMLib.Var.data.zhjhje);
	$("#sqrq1").datebox('setValue',parent.YMLib.Var.data.sqrq.substring(0,10));
	$("#sqrq").val(parent.YMLib.Var.data.sqrq);
	$("#bz").val(parent.YMLib.Var.data.bz);
	sumye(parent.YMLib.Var.data.id);
	$("#xmlx").val(parent.YMLib.Var.data.xmlx);
	//loadBmbm('xmlx','报表项目类型');
	//$("#xmlx").combobox('setValue',parent.YMLib.Var.data.xmlx);
})

    
function sumye(id){
	$.ajax({
		url:'/jxcsxm/tjbb/sumyeBycgsBJID.do',
		data:"cgsjhlrMx.id="+id,
		type:'post',
		dataType:'json',
		success:function(msg){
			
			var nums = (accSub(msg.jhje,msg.zhjhje));
			$("#syxmjhje").val(nums);
			$("#syxmjhje").html("资金不能大于:["+nums+"]万元");
			$("#ysqje").val(msg.bcje);
			//$("#ysqje").html("累计申请金额(不含本次):["+msg.bcje+"]万元，不能大于：["+accSub($('#zhjhje').val(),msg.bcje)+"]");
			$("#ysqje").html("累计申请金额(不含本次):["+msg.bcje+"]万元，不能大于：["+accSub($('#zhjhje').val(),msg.bcje)+"]");
		}
			
	})
}
function sqXmbj(){
	
	$('#sqrq').val($('#sqrq1').datebox("getValue"));
	
	if($("#bcje").val()==''||$("#bcje").val()==null){
		alert("本次金额不能为空");
		return;
	}
	
	if($("#zhjhje").val()==''||$("#zhjhje").val()==null){
		alert("用户计划金额不能为空");
		return;
	}
	if(accSub($("#zhjhje").val(),$("#syxmjhje").val())>0 ){
		
		alert("累计用户计划金额超过了项目计划金额");
		return;
	}
	if(accSub(accAdd($("#ysqje").val(),$("#bcje").val()),$("#zhjhje").val())>0){
		alert("累计申请金额超过了用户计划金额");
		return;
	}
		$('#submit').ajaxSubmit({
			dataType:'json',
			success:function(msg){
				if(msg){
					//disLoadjzt();
					alert("保存成功！");
					//zjdwxz();
					//sumye($("#id").val());
					//queryysqlist($("#id").val());
					 parent.$("#ysqlb").datagrid('reload');
					 closeWindow();
				}else{
			        //disLoadjzt();
					alert("保存失败！");
				}
			},
			error:function(msg){
				disLoadjzt();
				alert("保存失败！");
			}
		});
	
	
}

</script>
</head>
<body>

<form id="submit" action="/jxcsxm/tjbb/updateSbzjcgsjhlrMx.do" method="post">
<table class='table' style="width: 100%; background-color: #FFE7BA; font-size: 12px"
			border="0" cellpadding="3" cellspacing="1">
			<tr style="height: 35px;">
				  
				<td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
				申请日期：</td>
				<td style="background-color: #ffffff; height: 20px;" align="left">
					<input type="text" class='easyui-datebox' name="sqrq1" id="sqrq1" style="width: 124px" />
				 	<input type="hidden" name="cgsjhlrMx.sqrq" id="sqrq" style="width: 124px" />
				 	<input type="hidden" name="cgsjhlrMx.id" id="id" style="width: 124px" />
				 	<input type="hidden" name="cgsjhlrMx.xmlx" id="xmlx" style="width: 124px" /></td>
				 	
			
				<td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
				用户计划金额：</td>
				<td style="background-color: #ffffff; height: 20px;" align="left">
					<input type="text" name="cgsjhlrMx.zhjhje" id="zhjhje" onchange="yhjhje(this)" style="width: 120px" />万元<span id="syxmjhje" style="color:red;"></span></td>
			</tr>
			<tr style="height: 35px;">
				<td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
				本次申请拨付金额：</td>
				<td style="background-color: #ffffff; height: 20px;" align="left">
					<input type="text" name="cgsjhlrMx.bcje" id="bcje" onchange="bcsqbfje(this)" style="width: 120px" />万元<span id="ysqje" style="color:red;"></span></td>
				<td colspan="2"></td>
				<!-- <td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
				项目类型：</td>
				<td style="background-color: #ffffff; height: 20px;" align="left">
				    <select id="xmlx" name="xmjbxx.xmlx" style="width: 100px;"></select>
                </td> -->
				
			</tr>
			</tr>
			
			<tr style="height: 35px;">
				<td style="background-color:#FFEFD5;color: #007DB3; font-weight: bold;" align="right">
				备注：</td>
				<td style="background-color: #ffffff; height: 20px;" align="left" colspan="3">
					<input type="text" name="cgsjhlrMx.bz" id="bz" style="width: 450px" /></td>
			</tr>
			
			<tr style="height: 35px;">
				<td colspan="4" style="background-color: #ffffff;"align="center">
				<a id='mybuttion1' style="margin-left: 5px;margin-bottom: 1px;" href="javascript:sqXmbj()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion1')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion1')"  class="button button-tiny button-rounded button-raised button-primary">保存</a>
				<a id='mybuttion2' style="margin-left: 5px;margin-bottom: 1px;" href="javascript:closeWindow()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion2')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion2')"  class="button button-tiny button-rounded button-raised button-primary">取消</a>
			
			</tr>
			
		</table>
	</form>
</body>
</html>